package com.broadengate.dao.impl;

import java.util.ArrayList;
import java.util.List;

import com.broadengate.dao.DepositDao;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.broadengate.model.Card;
import com.broadengate.model.Deposit;

/******
 * 提供存款时与数据库的交互方法
 * 方法主要有deposit()实现存款；deleteDepositByCard()删除存款记录
 */
public class DepositDaoImpl extends HibernateDaoSupport implements DepositDao {
	
	public void deposit(Card card, Deposit deposit) {
		getHibernateTemplate().update(card);
		getHibernateTemplate().save(deposit);
	}
	
	public void deleteDepositByCard(String cardNO){
		
		List<Deposit> list = new ArrayList<Deposit>();
		list= getHibernateTemplate().find("from Deposit deposit where deposit.card.cardNo='"+cardNO+"'");
		getHibernateTemplate().delete(list);
		
		//list.removeAll(c);
		//list.clear();

			
	}
}
